package org.jks.controller;

import org.jks.enums.Sex;
import org.jks.model.User;
import org.jks.service.impl.UserServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

@Component
@Scope("singleton")
public class InitController {

	@Autowired
	public InitController(UserServiceImpl userImpl){
		User user = userImpl.findByName("admin");
		if(user == null){
			//初始化admin账户
			user = new User();
			user.setEmail("admin@admin.com");
			user.setUsername("admin");
			user.setPassword("admin");
			user.setGender(Sex.MAN.getValue());
			userImpl.saveOrUpdate(user);
		}
	}
}
